package com.czd.support.service;

import com.czd.base.model.Paginate;
import com.czd.base.service.BaseService;
import com.czd.support.common.Configuration;
import com.czd.support.model.Question2;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Author: Jerry.hu
 * Create: Jerry.hu (2014-10-03 12:28)
 * Description:
 * To change this template use File | Settings | File Templates.
 */
@Service
public class QuestionService extends BaseService<Question2> {

    public Paginate queryForPaginate(Question2 question2){
        question2.setPageSize(Configuration.getInstance().getDefault_page_size());
        return this.queryForPaginate(sqlId("queryForPaginate"),sqlId("questionCount"),question2);
    }

    public boolean insert(Question2 question){
        return this.insertAndReturnId(sqlId("insert"), question) > 0;
    }

    public Question2 findById(int id) {
        return this.selectOne(sqlId("findById"),id);
    }

    public boolean update(Question2 question) {
        return this.update(sqlId("update"),question);
    }

    public List<Question2> queryQuestionByAId(int aId) {
        return this.selectList(sqlId("queryQuestionByAId"),aId);
    }

    public List<Question2> queryAllQA() {
        return this.selectList(sqlId("queryAllQA"));
    }

    public List<Question2> queryQAByRoomId(int roomId) {
        return this.selectList(sqlId("queryQAByRoomId"),roomId);
    }

    public boolean deleteById(int id){
        return  this.delete(sqlId("deleteById"),id);
    }
}
